package com.k2data.k2app.service;

import com.k2data.k2app.domain.SysMessage;
import com.k2data.k2app.mapper.SysMessageMapper;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

/**
 * @author lidong 17-3-6.
 */
@Log4j2
@Service
public class SysMessageService {

    private final SysMessageMapper sysMessageMapper;

    @Autowired
    public SysMessageService(SysMessageMapper sysMessageMapper) {
        this.sysMessageMapper = sysMessageMapper;
    }

    public Map<String,List<SysMessage>> getByType(String type){
        List<SysMessage> list = sysMessageMapper.getByType(type);
        Map<String,List<SysMessage>> map = list.stream().collect(Collectors.groupingBy(SysMessage::getType));
        return map;
    }

}
